package com.tools.mytools;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.tools.common.utils.PermissionManager;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BaseActivity extends AppCompatActivity {
    private Unbinder mUnbinder;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(getLayoutResId());
        mUnbinder = ButterKnife.bind(this);
        PermissionManager.setActivity(this);
        doActivityInit(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        PermissionManager.setActivity(null);
        if(mUnbinder != null) {
            mUnbinder.unbind();
        }
    }

    protected void doActivityInit(Bundle savedInstanceState) {}

    protected abstract int getLayoutResId();
}
